package com.atgion.manager.controller;


import com.atgion.manager.service.ImageService;
import com.atgion.spzx.model.vo.base.Result;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import com.atgion.spzx.model.entity.ImageManagement.Images;

@Slf4j
@Tag(name = "SysMenuController", description = "菜单信息控制层")
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/image/")
public class ImageController {


    private final ImageService imageService;

    @GetMapping
    public Result<Page<Images>> findByPage(Integer page, Integer limit, Integer categoryId, Integer isVideo) {
        Page<Images> pageInfo = imageService.findByPage(page, limit, categoryId,isVideo);
        return Result.success(pageInfo) ;
    }

    @PostMapping("/save")
    public Result save(@RequestBody Images Images) {
        Images.setIsDeleted(0);
        if(Images.getCategoryId()==null)Images.setCategoryId(-1);
        imageService.save(Images);
        return Result.success() ;
    }

    @DeleteMapping("/remove")
    public Result remove(@RequestBody List<Integer> id) {
        imageService.removeByids(id);
        return Result.success() ;
    }

    @GetMapping("/UpdateImageById/{ImageById}/{id}")
    public Result UpdateImageById(
            @PathVariable("ImageById") Integer ImageById,
            @PathVariable("id") Integer id){

        imageService.UpdateImageById(ImageById,id);
        return Result.success() ;
    }
}
